<template>
  <view>
    <!-- 列表 -->
    <scroll-view :scroll-y="true" style="height: 100%; width: 100%;" class="container item one">
      <view class="container-body u-p-b-30">
        <template v-if="list && list.length">
          <u-card
            :border="false"
            box-shadow="0px 0px 8px #ddd6d6"
            :body-style="{padding:'0 30rpx 10rpx'}"
            v-for="(item, index)  in list"
            :key="index"
          >
            <view slot="head">
              <view class="card-row u-flex u-row-between">
                <view class="card-row-title u-flex">
                  <u-line color="#014833" direction="col" :hair-line="false" margin="0 20rpx 0 0" length="40rpx"/>
                  <text class="t-green f-bold u-font-lg">{{ item.licenceName }}</text>
                </view>
              </view>
            </view>
            <view slot="body">
              <view v-if="item.src.length !== 0" class="card-row u-flex u-flex-wrap u-p-t-20 u-p-b-20">
                <u-image
                  class="u-m-r-10"
                  v-for="(list,index) in item.src"
                  :key="index"
                  border-radius="30"
                  width="280rpx"
                  height="210rpx"
                  :src="list"
                  @click="viewPic(item.src, index)"
                ></u-image>
              </view>
              <view v-else class="card-row u-flex u-flex-wrap u-p-t-20 u-p-b-20">
                <u-image border-radius="30" width="280rpx" height="210rpx" :src="pic_miss"></u-image>
              </view>
            </view>
          </u-card>
        </template>
        <template v-if="showEmpty">
          <view class="c-empty p-absolute-center">
            <u-empty text="暂无数据"></u-empty>
          </view>
        </template>
      </view>
    </scroll-view>
  </view>
</template>

<script>
import { BASE_IP, BASE_URL } from '@/utils/ip.js'
export default {
  name: 'index',
  props: {
    customerId: {
      type: String,
      default: ''
    },
    superviseIndustry: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      search: {
        archivesType: '0',
        customerId: '',
        industry: '',
        materialType: '002',
        type: ''
      },
      pic_miss: require('@/static/image/picture_missing.png'),
      tagColor: ['#49BDCC', '#dd524d'],
      type: '1',
      state: '',
      coalMineName: '',
      triggered: false, // 下拉刷新
      showEmpty: false,
      list: [],
      BASE_IP: '',
      BASE_URL: ''
    }
  },
  mounted() {
    this.BASE_URL = BASE_URL
    this.BASE_IP = BASE_IP
    this.getData()
  },
  methods: {
    /**
     * 初始化
     */
    init() {
      this.showEmpty = false
    },
    viewPic(data, index) {
      uni.previewImage({
        current: index,
        urls: data,
        longPressActions: {}
      })
    },
    /**
     * 请求数据
     */
    async getData() {
      this.$set(this.search, 'customerId', this.customerId)
      this.$set(this.search, 'industry', this.superviseIndustry)
      const res = await this.$post('/mobile/enterpriseInfo/enLicence/dataList', this.search)
      if (res && res.body) {
        this.list = res.body
        for (let i = 0; i < this.list.length; i++) {
          for (let j = 0; j < this.list[i].src.length; j++) {
            // #ifdef  H5
            this.list[i].src[j] = BASE_IP + BASE_URL + 'system/archives/preview/thumb/' + this.list[i].src[j]
            // #endif
            // #ifndef H5
            this.list[i].src[j] = BASE_URL + '/system/archives/preview/thumb/' + this.list[i].src[j]
            // #endif
          }
        }
        // 数据空
        if (this.list && this.list.length === 0) this.showEmpty = true
      }
    }
  }
}
</script>

<style lang="scss" scoped>
</style>
